home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / boss_sup.zip / BOSSDEMO.C < prev    next >
Text File  |  1992-03-06  |  22KB  |  620 lines

  1. /*
  2. ** Demo for The Window Boss
  3. **
  4. ** Copyright (c) 1985-1990 - Philip A. Mongelluzzo
  5. ** All rights reserved.
  6. **
  7. */
  8.  
  9. #include "winboss.h"                    /* windows header file */
  10.  
  11. #if DLC
  12. int _stack = 8192;                      /* Datalight C */
  13. #endif
  14.  
  15. #if BORLAND
  16. unsigned _stklen = 8192;
  17. #endif
  18.  
  19. #if __TSC__
  20. #define MAXWIN 50                       /* TopSpeed C */
  21. #else
  22. #define MAXWIN 100                      /* for 100 windows */
  23. #endif
  24.  
  25. WINDOWPTR wins[MAXWIN];                 /* DONT INCREASE IN SMALL MODEL */
  26.  
  27. unsigned blue = BLUE;                   /* remap for mono */
  28.  
  29. /*
  30. ** Prototypes to keep the new ANSI Compilers Happy
  31. */
  32.  
  33. #if BORLAND | WATCOM | MSC
  34. int main(int argc, char **argv);
  35. int dedemo(void);
  36. int pddemo(WINDOWPTR w);
  37. int nap(int ticks);
  38. int hiber(int seconds);
  39. int chkesc(void);
  40. int paktc(void);
  41. #endif
  42.  
  43. main(argc,argv)
  44. int argc;
  45. char *argv[];
  46. {
  47. WINDOWPTR     w2, w3;                   /* a few windows */
  48. WINDOWPTR tw1, tw2, tw3;                /* and a few more */
  49.  
  50. WINDOWPTR wn_qpopup();                  /* function returns WP */
  51. int i,j;                                /* scratch integers */
  52. int t50rib;                             /* top 50 atrib */
  53. int watrib,batrib;                      /* scratch atributes */
  54. int rv;                                 /* for popup */
  55. int row,col;                            /* for 100 windows */
  56.  
  57.   static struct pmenu m1 = {
  58.     00, FALSE, 00,
  59.     00, 00, {
  60.     01, 02, "Presenting", 0,
  61.     99, 99, "",99 }
  62.   };
  63.  
  64.   static struct pmenu m2 = {
  65.     00, FALSE, 00,
  66.     00, 00, {
  67.     01, 02, "The", 0,
  68.     03, 02, "W i n d o w   B O S S", 0,
  69.     05, 02, "Fast - Easy - Windows", 0,
  70.     07, 02, "for the C Language", 0,
  71.     99, 99, "",99 }
  72.   };
  73.  
  74.   static struct pmenu intelc = {
  75.     00, FALSE, 00,
  76.     02, 06, {
  77.     01, 02, "         Intellicom", 0,
  78.     02, 02, "        Quick - Help", 0,
  79.     04, 05, "1 General Information  ", 1,
  80.     05, 05, "2 Terminal Mode Options", 2,
  81.     06, 05, "3 XMODEM File Send     ", 3,
  82.     07, 05, "4 XMODEM File Receive  ", 4,
  83. #if MSC | DLC | CI86 | LC3
  84.      8, 05, "5 CompuServe Exec Mode ", 5,
  85. #else
  86.     08, 05, "5 CompuServe Exec Mode ", 5,
  87. #endif
  88.     10, 02, "Press: ESC to quit or Cursor", 0,
  89.     11, 02, " Keys to Position Cursor then", 0,
  90.     12, 02, " press RETURN for MORE info.", 0,
  91.     99, 99, "",99 }
  92.   };
  93.  
  94. if(argc > 2) wn_dmaflg=FALSE;         /* for testing bios access */
  95.   if(wns_mtflg == 7) blue = BLACK;      /* remap if mono */
  96.   if(argc > 1) wn_dmode(PAINT);         /* pretend CGA */
  97.  
  98.   wn_init();                            /* save entry screen */
  99.  
  100.   batrib = v_setatr(WHITE,BLACK,0,BOLD);/* set border atrib */
  101.   watrib = v_setatr(WHITE,RED,0,0);     /* make it american */
  102.   w2 = wn_qpopup(0,0,0,16,3,watrib,batrib,&m1);
  103.   for(i=1; i<11; i++)                   /* move it into place */
  104.     w2 = wn_move(w2, i, i*2);
  105.  
  106.   hiber(1);                             /* wait 1 second (aprx) */
  107.  
  108.   batrib = v_setatr(RED,WHITE,0,BOLD);  /* set border atrib */
  109.   watrib = v_setatr(blue,WHITE,0,BOLD); /* make this american too */
  110.   w3 = wn_qpopup(0,0,0,30,9,watrib|BOLD,batrib,&m2);
  111.   for(i=1; i<8; i++)                    /* move into place */
  112.     w3 = wn_move(w3,i,6*i);             /* move into place */
  113.  
  114.   hiber(5);                             /* reading time.. */
  115.  
  116.   wn_clr(w3);
  117.   wn_title(w3," PLEASE NOTE ");
  118.   wn_printf(w3,"\n");
  119.   wn_printf(w3,"This demo contains reading\n");
  120.   wn_printf(w3,"time delays that you can\n");
  121.   wn_printf(w3,"shorten by pressing the ESC\n");
  122.   wn_printf(w3,"key.\n\n");
  123.   wn_printf(w3,"Press any key to continue...");
  124.   paktc();
  125.  
  126.   wn_close(w3);                         /* close a couple */
  127.   hiber(1);
  128.   wn_close(w2);
  129.   hiber(1);
  130.  
  131.   watrib = v_setatr(WHITE,BLACK,0,BOLD);
  132.   for(i=0; i<25; i++) {                 /* build the back drop */
  133.     v_locate(0,i,0);                    /* position cursor */
  134.     v_wca(0, 0xb0, watrib, 80);         /* the fast way */
  135.   }
  136.   v_hidec();                            /* hide the cursor */
  137.  
  138.   watrib = v_setatr(WHITE,BLACK,0,0);   /* window attribute */
  139.   batrib = v_setatr(blue,WHITE,0,0);    /* border attribute */
  140.   w3 = wn_open(800,1,9,60,21,watrib,batrib);
  141.   w3->bstyle |= BOLD;                   /* toggle bold on then off */
  142.   wn_title(w3," The Window BOSS for C ");
  143.   w3->bstyle ^= BOLD;
  144.   wn_puts(w3,1,1,"The Window BOSS puts YOU in control of the most important");
  145.   wn_puts(w3,2,1,"sophisticated state-of-the-art screen handling techniques");
  146.   wn_puts(w3,3,1,"available today.  Pop-up windows, pull-down menus, status ");
  147.   wn_puts(w3,4,1,"lines and context sensitive help functions are a breeze ");
  148.   wn_puts(w3,5,1,"to implement!  Your program automatically senses the ");
  149.   wn_puts(w3,6,1,"video card installed and ALL your video output takes ");
  150.   wn_puts(w3,7,1,"place with no snow, no flicker, and no delay. But best of");
  151.   wn_puts(w3,8,1,"all, The Window BOSS is available as SHAREWARE software!");
  152.   wn_puts(w3,9,1," ");
  153.   wn_puts(w3,10,1,"The Window BOSS is available for compilers from Microsoft,");
  154.   wn_puts(w3,11,1,"Borland, WATCOM, Mix, JPI, Zortech, and Lattice. Users who");
  155.   wn_puts(w3,12,1,"register receive complete documentation, all source code,");
  156.   wn_puts(w3,13,1,"and support for all your compilers memory models!!    ");
  157.   wn_puts(w3,14,1," ");
  158.   wn_puts(w3,15,1,"I challenge you to compare: The Window BOSS is faster");
  159.   wn_puts(w3,16,1,"and easier to use than most commercial products on the");
  160.   wn_puts(w3,17,1,"market today! Others seem to agree too! Browse through");
  161.   wn_puts(w3,18,1,"the Cosmetic Surgery article in the September '91 issue");
  162.   wn_puts(w3,19,1,"of Computer Language Magazine for starters....");
  163.   hiber(30);
  164.  
  165.   wn_clr(w3);
  166.   wn_puts(w3, 1,1,"Tim Parker's column in the February 87 issue of Computer ");
  167.   wn_puts(w3, 2,1,"Language stated \"the ease of use will cause some ");
  168.   wn_puts(w3, 3,1,"programmers to go overboard with windows\", and \"if you ");
  169.   wn_puts(w3, 4,1,"are a die-hard C programmer looking for a useful, ");
  170.   wn_puts(w3, 5,1,"license-free product, this is it\".");
  171.   wn_puts(w3, 6,1," ");
  172.   wn_puts(w3, 7,1,"Hardin Bothers' column in the June 88 issue of PC ");
  173.   wn_puts(w3, 8,1,"Resource stated \"Within its domain, The Window BOSS is ");
  174.   wn_puts(w3, 9,1,"as useful and as powerful as any C library I've used\". ");
  175.   wn_puts(w3,10,1,"\"The Window BOSS owes much of its power to its ");
  176.   wn_puts(w3,11,1,"uncluttered organization. Although the product supports ");
  177.   wn_puts(w3,12,1,"five C Compilers - Microsoft C, Lattice C, Borland's ");
  178.   wn_puts(w3,13,1,"Turbo C, Computer Innovations CI86, and Datalight C - it ");
  179.   wn_puts(w3,14,1,"does it with a minimum of fuss\".");
  180.   wn_puts(w3,15,1," ");
  181.   wn_puts(w3,16,1,"The BOSS is currently being used by dozens of Fortune ");
  182.   wn_puts(w3,17,1,"500 Companies, numerous universities, and discriminating ");
  183.   wn_puts(w3,18,1,"\"C\" programmers around the world!  Haven't you waited ");
  184.   wn_puts(w3,19,1,"long enough?");
  185.   hiber(30);
  186.  
  187.  
  188.   wn_clr(w3);
  189.   wn_puts(w3, 1,1,"  Psst...");
  190.   wn_puts(w3, 2,1,"  ");
  191.   wn_puts(w3, 3,1,"    The Window BOSS is one of ");
  192.   wn_puts(w3, 4,1,"               PC-SIG's TOP 50 Best Selling Programs");
  193.   wn_puts(w3, 5,1,"  ");
  194.   wn_puts(w3, 6,1,"              ██████     █████      █████ ");
  195.   wn_puts(w3, 7,1,"                ██       █   █      █   █");
  196.   wn_puts(w3, 8,1,"                ██       █   █      █████");
  197.   wn_puts(w3, 9,1,"                ██       █   █      ██");
  198.   wn_puts(w3,10,1,"                ██       █████      ██");
  199.   wn_puts(w3,11,1,"  ");
  200.   wn_puts(w3,12,1,"                   █████      █████");
  201.   wn_puts(w3,13,1,"                   █          █   █");
  202.   wn_puts(w3,14,1,"                   █████      █   █");
  203.   wn_puts(w3,15,1,"                       █      █   █");
  204.   wn_puts(w3,16,1,"                   █████      █████");
  205.   wn_puts(w3,17,1,"  ");
  206.   wn_puts(w3,18,1,"            Shareware Magazine Jan-Feb 1990");
  207.   wn_puts(w3,19,1,"  ");
  208.   for(j=0; j<=WHITE; j++) {
  209.     t50rib = v_setatr(WHITE,j,0,BOLD);
  210.     wn_natrib(w3,t50rib);
  211.   }
  212.   wn_dmode(PAINT);
  213.   wn_natrib(w3,watrib);
  214.   wn_dmode(FLASH);
  215.   hiber(5);
  216.  
  217.   watrib = v_setatr(WHITE,blue,0,0);    /* window attribute */
  218.   batrib = v_setatr(RED,WHITE,0,BOLD);  /* border attribute */
  219.   w2 = wn_open(0,5,5,50,10,watrib,batrib);
  220.   if(!w2) exit(1);                      /* yes.. it should be better */
  221.   wn_puts(w2,0,0," Simple text output is very fast");
  222.   wn_puts(w2,1,0," and snow free.");
  223.   wn_puts(w2,3,0," Watch this....");
  224.   hiber(3);
  225.   wn_clr(w2);                           /* clear it then fill it */
  226.   for(i=0; i<10; i++)
  227.     wn_puts(w2,i,0," Very fast screen output - no snow!");
  228.   hiber(5);
  229.   wn_clr(w2);                           /* do it again */
  230.   for(i=0; i<10; i++)
  231.     wn_puts(w2,i,0," Another window full of fast text.");
  232.   hiber(5);
  233.  
  234.   wn_clr(w2);
  235.   wn_printf(w2," The BOSS also supports a printf function!\n");
  236.   wn_printf(w2," Its as simple as:\n\n");
  237.   wn_printf(w2," \twn_printf(wn,\"%%d\\n\",i);\n\n");
  238.   wn_printf(w2," to print a value in a window.\n\n");
  239.   wn_printf(w2," Scrolling works too\n");
  240.   wn_printf(w2," Lets count (slowly) to 10...\n");
  241.   wn_sync(w2, TRUE);
  242.   hiber(10);
  243.   for(i=1;i<11;i++) {
  244.     wn_printf(w2," The count is: %d\n", i);
  245.     nap(5);
  246.   }
  247.   wn_printf(w2," Ok, lets see what it looks like at\n");
  248.   wn_printf(w2," full speed.. (counting to 25)\n");
  249.   hiber(5);
  250.   for(i=1;i<26;i++)
  251.     wn_printf(w2," The count is: %d\n", i);
  252.   hiber(5);                             /* reading time */
  253.   wn_sync(w2, FALSE);
  254.   v_hidec();
  255.  
  256.   wn_clr(w2);
  257.   wn_putsa(w2,0,0," Full color support is provided.",WHITE<<4);
  258.   for(i=1; i<6; i++)
  259.     wn_putsa(w2,i,0, " Add a little color to your life.",WHITE<<4|i);
  260.   wn_putsa(w2,6,0," As is window movement....watch...",WHITE<<4|BLACK);
  261.   hiber(5);
  262.  
  263.   for(i=0; i<13; i++)                   /* move the window around */
  264.     w2 = wn_move(w2, i, i*2);
  265.   hiber(5);
  266.   wn_printf(w2,"\n Lets put it back where we started...\n");
  267.   hiber(3);
  268.   w2 = wn_move(w2,5,5);
  269.   wn_printf(w2," Now, lets add a title to our window!\n");
  270.   hiber(3);
  271.   w2->bstyle |= BOLD;
  272.   wn_title(w2," Pretty Powerful Stuff ");
  273.   w2->bstyle ^= BOLD;
  274.   hiber(5);
  275.  
  276. /* ============================= Tiled Window Stuff ===================== */
  277.  
  278.   wn_printf(w2," Tiled windows are supported\n");
  279.   wn_printf(w2," Lets add three.\n");
  280.   hiber(5);
  281.  
  282.   wn_sbit=FAST;
  283.   tw1 = wn_open(510,3,5,40,10, RED<<4|YELLOW|BOLD, RED<<4|WHITE|BOLD);
  284.   wn_sync(tw1,TRUE);
  285.   wn_printf(tw1,"ONE\n");
  286.   tw2 = wn_open(510,6,8,40,10, blue<<4|WHITE|BOLD, blue<<4|GREEN|BOLD);
  287.   wn_sync(tw2,TRUE);
  288.   wn_printf(tw2,"TWO\n");
  289.   tw3 = wn_open(510,9,11,40,10,GREEN<<4|WHITE|BOLD, GREEN<<4|WHITE|BOLD);
  290.   wn_sync(tw3,TRUE);
  291.   wn_printf(tw3,"THREE\n");
  292.   wn_printf(tw3," Press a key and watch TWO move\n");
  293.   wn_printf(tw3," To the top!!\n");
  294.   v_getch();
  295.  
  296.   wn_activate(tw2);
  297.   wn_printf(tw2," Press a key and watch THREE move\n");
  298.   wn_printf(tw2," To the top!!\n");
  299.   v_getch();
  300.   wn_activate(tw3);
  301.   wn_printf(tw3," Press a key and watch ONE move\n");
  302.   wn_printf(tw3," To the top!!\n");
  303.   v_getch();
  304.   wn_activate(tw1);
  305.  
  306.   wn_printf(tw1, " Ok..Press a key\n");
  307.   wn_printf(tw1, " and we will continue with the show!");
  308.   v_getch();
  309.  
  310.   wn_close(tw1);
  311.   wn_close(tw3);
  312.   wn_close(tw2);
  313.  
  314.   wn_clr(w2);
  315.   wn_printf(w2," 100 are as easy as 3!!\n");
  316.   wn_printf(w2," Press any key please..\n");
  317.   v_getch();
  318.  
  319.   for (i = 0; i < MAXWIN; i++) {
  320.      row = (rand() % 12) +3;
  321.      col = (rand() % 62) +2;
  322.      batrib = rand() % 16;
  323.      watrib = rand() % 128;
  324.      if(wns_mtflg == 7) {
  325.        batrib = v_setatr(BLACK,WHITE,0,BOLD);
  326.        watrib = v_setatr(BLACK,WHITE,0,BOLD);
  327.      }
  328.      wins[i] = wn_open(0,row,col,11,7,watrib, batrib);
  329.      if(!wins[i]) {
  330.        v_locate(0,0,0);
  331.        v_cls(NORMAL);
  332.        printf("wn_open failed...reduce MAXWIN!!\n");
  333.        exit(1);
  334.      }
  335.      wn_printf(wins[i],"%d",i);
  336.   }
  337.   hiber(5);
  338.  
  339.   wn_clr(w2);
  340.   wn_printf(w2," Lets activate the bottom 10 one at a time.\n");
  341.   wn_printf(w2," When you hear the beep press a key...\n");
  342.   hiber(5);
  343.  
  344.   paktc();
  345.   for(i=0;i<10;i++) {
  346.     wn_printf(wins[i]," Activated!\n");
  347.     paktc();
  348.   }
  349.  
  350.   wn_clr(w2);
  351.   wn_printf(w2, " Truly Powerful Stuff!!\n");
  352.   wn_printf(w2, " Ok..Press a key\n");
  353.   wn_printf(w2, " and we will SLOWLY close all 100 windows by\n");
  354.   wn_printf(w2, " floating each window to the top of the stack\n");
  355.   wn_printf(w2, " and restoring the image that existed prior to\n");
  356.   wn_printf(w2, " the window being opened. Concurrently, all \n");
  357.   wn_printf(w2, " other hidden images will be adjusted to reflect\n");
  358.   wn_printf(w2, " the fact that a window has vanished!!\n");
  359.   v_getch();
  360.  
  361.   for(i=MAXWIN-1; i>=0; i--) {
  362.     wn_printf(wins[i]," Closing\n");
  363.     nap(2);
  364.     if(!wn_close(wins[i])) {
  365.       v_cls(7);
  366.       v_locate(0,0,0);
  367.       printf("wn_close failed!\n");
  368.       exit(1);
  369.     }
  370.   }
  371.  
  372.   wn_sbit=SLOW;
  373.  
  374. /* ========================= Popup & Help Stuff ========================= */
  375.  
  376.   wn_clr(w2);
  377.   wn_printf(w2," Popup Menus are a breeze.\n\n");
  378.   wn_printf(w2," Watch....");
  379.   hiber(2);
  380.   if(!wn_hlinit(0,0,78,23,BLUE<<4 | WHITE, BLUE<<4 | WHITE,"intelc")) {
  381.     v_locate(0,0,0);
  382.     printf("wn_hlinit failed!\n");
  383.     exit(0);
  384.   }
  385.   do {
  386.     rv = wn_popup(0,0,0,33,14, WHITE<<4|BLACK, blue<<4|WHITE, &intelc,FALSE);
  387.  
  388.     switch (rv) {                       /* dispatch */
  389.       case 1:
  390.         wn_help("%general information%");
  391.         break;
  392.       case 2:
  393.         wn_help("%terminal%");
  394.         break;
  395.       case 3:
  396.         wn_help("%checksum xmit1%");
  397.         break;
  398.       case 4:
  399.         wn_help("%checksum recv1%");
  400.         break;
  401.       case 5:
  402.         wn_help("%cistty1%");
  403.         break;
  404.       case 99:
  405.       default:
  406.         break;
  407.     }
  408.   } while(rv !=99);
  409.  
  410. /***************************** Pulldown Stuff *****************************/
  411.  
  412.   wn_clr(w2);                           /* setup for pulldown */
  413.   wn_printf(w2," Pulldown Menus are easy too!!\n\n");
  414.   wn_printf(w2," Watch....");
  415.   hiber(2);
  416.   pddemo(w2);                           /* pulldown sample */
  417.  
  418. /***************************** Data Entry Stuff **************************/
  419.  
  420.                                         /* set up for data entry */
  421.   wn_clr(w2);
  422.   wn_printf(w2," Naturally, The Window BOSS fully supports\n");
  423.   wn_printf(w2," data entry in windows!!\n\n");
  424.   wn_printf(w2," Lets try a small sample ....");
  425.   hiber(5);
  426.   dedemo();                             /* do the data entry demo */
  427.  
  428. /**************************** Summary Stuff *******************************/
  429.  
  430.   wn_clr(w2);                           /* clear the window */
  431.   w2->bstyle |= BOLD;                   /* toggle bold on then off */
  432.   wn_title(w2," The Window BOSS for C ");
  433.   w2->bstyle ^= BOLD;
  434.   wn_printf(w2,"\n\n  The following is a quick summary\n");
  435.   wn_printf(w2,"  of SOME of the functions available...");
  436.   hiber(4);
  437.  
  438.   wn_help("%bossinfo%");                /* provide some details */
  439.  
  440.   wn_clr(w2);                           /* and now the credits */
  441.   wn_printf(w2,"\n\n\n");
  442.   wn_printf(w2,"                  The Window BOSS\n");
  443.   wn_printf(w2,"             Copyright (c) 1985 - 1992\n");
  444.   wn_printf(w2,"              Philip  A. Mongelluzzo\n");
  445.   wn_printf(w2,"                 273 Windy Drive\n");
  446.   wn_printf(w2,"              Waterbury, Conn  06705\n");
  447.  
  448.   wn_printf(w2,"\n\t\t\t\tThats all folks...\n\n");
  449.  
  450.   hiber(5);                             /* all done ! */
  451.   wn_close(w2);
  452.   wn_close(w3);
  453.   wn_exit();                            /* restore entry screen */
  454.   exit(0);
  455. }
  456.  
  457. /************************* Data Entry Demo Code ***************************/
  458.  
  459. dedemo()                                /* data entry demo */
  460. {
  461. WINDOWPTR wn;                           /* window pointer */
  462. WIFORM frm;                             /* form pointer */
  463. static struct db {                      /* record layout */
  464.   char  date[10];                       /* date string */
  465.   int   month,day,year;                 /* date numerics */
  466.   char  time[10];                       /* time string */
  467.   int   thrs,tmin,tsec;                 /* time numerics */
  468.   char  name[32];                       /* name */
  469.   char  adr[32];                        /* street address */
  470.   char  city[17];                       /* city */
  471.   char  st[4];                          /* state */
  472.   char  zip[8];                         /* zip */
  473.   char  phone[18];                      /* phone string */
  474.   int   ac, nnx, num;                   /* phone numerics */
  475.   char  age[4];                         /* age */
  476.   int   old;                            /* age numeric */
  477. } rec;
  478. unsigned atrib;                         /* data entry field atribute */
  479. char *emsg1,*emsg2,*emsg3;              /* error msg ptr */
  480. char fchar;                             /* fill character */
  481.  
  482.                                         /* open window */
  483.   wn = wn_open(0,10,10,42,9,(BLUE<<4|YELLOW|BOLD),(BLUE<<4|WHITE|BOLD));
  484.   if(!(wn)) {                           /* errors ?? */
  485.     printf("wn_open failed!!\n");       /* tell of woe... */
  486.     exit(1);                            /* and die */
  487.   }
  488.   wn_title(wn," Sample Data Entry Form ");
  489.  
  490.   frm = wn_frmopn(11);                  /* form open for 10 fields */
  491.   if(!frm) {                            /* errors ?? */
  492.     printf("wn_frmopn failed!!\n");     /* tell of woe... */
  493.     exit(1);                            /* and die */
  494.   }
  495.  
  496.   atrib = (BLUE<<4) | WHITE | BOLD;     /* field attribute */
  497.   *rec.date = NUL;                      /* set edit buffer to zip */
  498.   *rec.time = NUL;                      /* set edit buffer to zip */
  499.   *rec.adr = NUL;                       /* set edit buffer to zip */
  500.   *rec.city = NUL;                      /* set edit buffer to zip */
  501.   *rec.st = NUL;                        /* set edit buffer to zip */
  502.   *rec.zip = NUL;                       /* set edit buffer to zip */
  503.   *rec.phone = NUL;                     /* set edit buffer to zip */
  504.   *rec.age = NUL;                       /* set edit buffer to zip */
  505.  
  506.   emsg1 = "Invalid date, press any key to continue...";
  507.   emsg2 = "Invalid time, press any key to continue...";
  508.   emsg3 = "Age must be between 1 and 99, press any key to continue...";
  509.  
  510.   fchar = '_';
  511.  
  512.   wn_gdate (SET,frm,0, wn,1,1, "Date: ",atrib,fchar,&rec.month,&rec.day,&rec.year,rec.date,NSTR,emsg1);
  513.   wn_gtime (SET,frm,1, wn,1,23,"Time: ",atrib,fchar,&rec.thrs,&rec.tsec,&rec.tmin, rec.time,NSTR,emsg2);
  514.   wn_gtext (SET,frm,2, wn,3,1, "Name: ",atrib,fchar,30,rec.name,NSTR,NSTR);
  515.   wn_gtext (SET,frm,3, wn,4,1, "Addr: ",atrib,fchar,30,rec.adr,NSTR,NSTR);
  516.   wn_gtext (SET,frm,4, wn,5,1, "City: ",atrib,fchar,15,rec.city,NSTR,NSTR);
  517.   wn_gutext(SET,frm,5, wn,5,23,  "ST: ",atrib,fchar,2,rec.st,NSTR,NSTR);
  518.   wn_gtext (SET,frm,6, wn,5,31, "Zip: ",atrib,fchar,5,rec.zip,NSTR,NSTR);
  519.   wn_gphone(SET,frm,7, wn,7,1, "Tele: ",atrib,fchar,&rec.ac,&rec.nnx,&rec.num,rec.phone,NSTR,NSTR);
  520.   wn_gint  (SET,frm,8, wn,7,23,"Age : ",atrib,fchar,&rec.old,2,1,99,rec.age,NSTR,emsg3);
  521.  
  522.   if(!wn_frmget(frm)) {                 /* get (read) form */
  523.     v_cls(7);                           /* die if errors !! */
  524.     v_locate(0,0,0);
  525.     printf("Memory Corruption Error!\n");
  526.     exit(1);
  527.   }
  528.  
  529.   wn_clr(wn);                           /* clear window & display data */
  530.   wn_printf(wn,"Data entered was:\n");
  531.   wn_printf(wn,"Date: %02d/%02d/%02d  ", rec.month, rec.day, rec.year);
  532.   wn_printf(wn,"Time: %02d:%02d:%02d\n", rec.thrs, rec.tmin, rec.tsec);
  533.   wn_printf(wn,"Name: %s\n",rec.name);
  534.   wn_printf(wn,"Adr:  %s\n",rec.adr);
  535.   wn_printf(wn,"City: %s ST: %s Zip: %s\n",rec.city, rec.st, rec.zip);
  536.   wn_printf(wn,"Tele: (%03d) %03d-%04d\n", rec.ac, rec.nnx, rec.num);
  537.   wn_printf(wn,"Age:  %2d\n",rec.old);
  538.   wn_printf(wn,"\nPress any key to continue..");
  539.   v_getch();
  540.  
  541.   wn_frmcls(frm);                       /* close for */
  542.   wn_close(wn);                         /* close window */
  543.   return(NULL);                         /* keep the compilers happy */
  544. }
  545.  
  546. /*********************** Pulldown Menu Code *******************************/
  547. pddemo(w)
  548. WINDOWPTR w;
  549. {
  550. FILE *f;
  551.  
  552.   f = fopen("pddemo.exe", "r");
  553.   if(f) {
  554.     fclose(f);
  555.     system("pddemo");
  556.     return;
  557.   }
  558.   wn_clr(w);
  559.   wn_printf(w, "Sorry, PDDEMO.EXE is not in\n");
  560.   wn_printf(w, "the current directory.  Pulldown\n");
  561.   wn_printf(w, "demo can not be conducted.\n\n");
  562.   v_wtty(BELL);
  563.   wn_printf(w, "Press any key to continue..");
  564.   v_getch();
  565.   return;
  566. }
  567.  
  568. /************************* Miscellaneous Code *****************************/
  569.  
  570. nap(ticks)                              /* sleep a few clock ticks */
  571. int ticks;
  572. {
  573. unsigned long tc;
  574. unsigned long ts, te;
  575.  
  576.   ts = wns_gticks();                    /* get current tick count */
  577.   do {
  578.     if(chkesc()) return(NULL);
  579.     te = wns_gticks();
  580.     tc = te-ts;
  581.   } while (tc < (unsigned long)ticks);
  582. }
  583.  
  584. hiber(seconds)
  585. int seconds;
  586. {
  587.   nap(seconds * 18);
  588.   return(NULL);
  589. }
  590.  
  591. chkesc()                                /* check for ESC while napping */
  592. {
  593. int c;
  594.  
  595.   if(v_kstat()) {
  596.     c=v_getch() & 0x7f;
  597.     switch(c) {
  598.       case ESC:
  599.         return(TRUE);
  600.       case ETX:
  601.         v_cls(7);
  602.         v_locate(0,0,0);
  603.         exit(0);
  604.       default:
  605.         return(FALSE);
  606.     }
  607.   }
  608.   return(FALSE);
  609. }
  610.  
  611. paktc()                                 /* press any key to continue */
  612. {
  613.   v_wtty(0x07);                         /* beep */
  614.   v_getch();
  615.   return(NULL);
  616. }
  617.  
  618. /* End */
  619. 
  620.